home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / newlooklib.lha / newlook / addgtext.c < prev    next >
C/C++ Source or Header  |  1993-10-24  |  924b  |  43 lines

  1. /*
  2.  *  ADDGTEXT.C
  3.  */
  4.  
  5. #include "newlook.h"
  6.  
  7. extern struct TextFont *OpenFont(struct TextAttr *);
  8. extern void CloseFont(struct TextFont *);
  9. extern LONG IntuiTextLength(struct IntuiText *);
  10.  
  11. struct IntuiText *AddGText(g,l,r)
  12. struct Gadget *g;
  13. STRPTR l,r;
  14. {
  15.   struct IntuiText *it= (struct IntuiText *)NULL;
  16.   struct TextFont *tf;
  17.  
  18.   SHORT tx, ty; /* text position */
  19.  
  20.   tx= ( (g->GadgetType == STRGADGET) ? 14:10 );
  21.  
  22.   if(tf= (struct TextFont *)OpenFont(&Topaz80))
  23.   { ty= (g->Height-tf->tf_Baseline)/2;
  24.     CloseFont(tf);
  25.   }
  26.   else ty= (g->Height-6)/2; /* `known' topaz80 dimensions */
  27.  
  28.   if(l && *l)
  29.   { if(it= CreateIText(-tx,ty,l))
  30.     { MoveIText(it,-IntuiTextLength(LastIText(it)),0);
  31.       LastIText(it)->NextText= g->GadgetText;
  32.       g->GadgetText= it;
  33.     }
  34.   }
  35.   if(r && *r)
  36.   { if(it= CreateIText(g->Width+tx,ty,r))
  37.     { LastIText(it)->NextText= g->GadgetText;
  38.       g->GadgetText= it;
  39.     }
  40.   }
  41.   return it;
  42. }
  43.